package com.ruoyi.buss.qmcy.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.buss.qmcy.domain.QmcyCustDkmx;
import com.ruoyi.buss.qmcy.service.IQmcyCustDkmxService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 贷款明细Controller
 * 
 * @author ruoyi
 * @date 2021-07-16
 */
@RestController
@RequestMapping("/dkmx")
public class QmcyCustDkmxController extends BaseController
{
    @Autowired
    private IQmcyCustDkmxService qmcyCustDkmxService;

    /**
     * 查询贷款明细列表
     */
    @PreAuthorize(hasPermi = "buss:dkmx:list")
    @GetMapping("/list")
    public TableDataInfo list(QmcyCustDkmx qmcyCustDkmx)
    {
        startPage();
        List<QmcyCustDkmx> list = qmcyCustDkmxService.selectQmcyCustDkmxList(qmcyCustDkmx);
        return getDataTable(list);
    }

    /**
     * 导出贷款明细列表
     */
    @PreAuthorize(hasPermi = "buss:dkmx:export")
    @Log(title = "贷款明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QmcyCustDkmx qmcyCustDkmx) throws IOException
    {
        List<QmcyCustDkmx> list = qmcyCustDkmxService.selectQmcyCustDkmxList(qmcyCustDkmx);
        ExcelUtil<QmcyCustDkmx> util = new ExcelUtil<QmcyCustDkmx>(QmcyCustDkmx.class);
        util.exportExcel(response, list, "贷款明细数据");
    }

    /**
     * 获取贷款明细详细信息
     */
    @PreAuthorize(hasPermi = "buss:dkmx:query")
    @GetMapping(value = "/{dkzh}")
    public AjaxResult getInfo(@PathVariable("dkzh") String dkzh)
    {
        return AjaxResult.success(qmcyCustDkmxService.selectQmcyCustDkmxById(dkzh));
    }

    /**
     * 新增贷款明细
     */
    @PreAuthorize(hasPermi = "buss:dkmx:add")
    @Log(title = "贷款明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QmcyCustDkmx qmcyCustDkmx)
    {
        return toAjax(qmcyCustDkmxService.insertQmcyCustDkmx(qmcyCustDkmx));
    }

    /**
     * 修改贷款明细
     */
    @PreAuthorize(hasPermi = "buss:dkmx:edit")
    @Log(title = "贷款明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QmcyCustDkmx qmcyCustDkmx)
    {
        return toAjax(qmcyCustDkmxService.updateQmcyCustDkmx(qmcyCustDkmx));
    }

    /**
     * 删除贷款明细
     */
    @PreAuthorize(hasPermi = "buss:dkmx:remove")
    @Log(title = "贷款明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dkzhs}")
    public AjaxResult remove(@PathVariable String[] dkzhs)
    {
        return toAjax(qmcyCustDkmxService.deleteQmcyCustDkmxByIds(dkzhs));
    }
}
